using UnityEngine;

namespace Gj
{
    public class MusicHelper : NodeHelper
    {
        public AudioClip music;
        public bool invert;
        public bool auto;
        private bool allow;

        protected override BindDataType bindDataType => BindDataType.Bool;

        protected override void Start()
        {
            base.Start();
            if (auto) Game.single.PlayBGM(music);
        }

        protected override void BindData(bool b)
        {
            var _allow = invert ? !b : b;
            if (_allow != allow && _allow) Game.single.PlayBGM(music);

            allow = _allow;
        }
    }
}